﻿<Page x:Class="NewMarkersSample.Pages.BarChartDataTriggerPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	  xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
	  xmlns:wpf="http://schemas.microsoft.com/wpf/2008/toolkit"
	  xmlns:local="clr-namespace:NewMarkersSample.Pages" Loaded="Page_Loaded"
    Title="Bar Chart">
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="Auto"/>
		</Grid.ColumnDefinitions>

		<d3:ChartPlotter Name="plotter">
			<d3:BarChart Name="barChart" ItemsSource="{Binding}" BoundsUnionMode="Bounds">
				<d3:TemplateMarkerGenerator>
					<DataTemplate>
						<Rectangle Width="30"
								   d3:ViewportPanel.Y="{Binding YMin}" 
								   d3:ViewportPanel.X="{Binding X}"
								   d3:ViewportPanel.ViewportHeight="{Binding YMax}"
								   d3:ViewportPanel.ViewportVerticalAlignment="Bottom">
							<Rectangle.Style>
								<Style TargetType="Rectangle">
									<Setter Property="Fill" Value="Orange"/>
									<Style.Triggers>
										<DataTrigger Binding="{Binding YMax}" Value="3.0">
											<Setter Property="Fill" Value="Blue"/>
										</DataTrigger>
									</Style.Triggers>
								</Style>
							</Rectangle.Style>

						</Rectangle>
					</DataTemplate>
				</d3:TemplateMarkerGenerator>
			</d3:BarChart>
		</d3:ChartPlotter>

		<wpf:DataGrid Name="dataGrid" Grid.Column="1" HorizontalAlignment="Center" AutoGenerateColumns="False"
					  ItemsSource="{Binding}" VerticalScrollBarVisibility="Auto">
			<wpf:DataGrid.Columns>
				<wpf:DataGridTextColumn Header="X" Binding="{Binding X}"/>
				<wpf:DataGridTextColumn Header="YMin" Binding="{Binding YMin}"/>
				<wpf:DataGridTextColumn Header="YMax" Binding="{Binding YMax}"/>
			</wpf:DataGrid.Columns>
		</wpf:DataGrid>
	</Grid>
</Page>
